<?php
if(!$isLogged){
?>
<script>
    $(function() {
        $('#submitIndexLoginBtnSmall').linkbutton();
        $('#formIndexLoginSmall').submit(function() {            
            if($(this).form('validate') && $('#userFieldSmall').val() && $('#passwordFieldSmall').val()){
                $('div#divLoader').window('open');
                $.ajax({
                    type: "post",
                    url: '<?php echo $this->Html->url(array('controller' => 'CoreUsers', 'action' => 'login'));?>',
                    data:{user: $('#userFieldSmall').val(), pass: $('#passwordFieldSmall').val()},
                
                    success: function(data) {
                        if(data=='true'){
                            location.reload();
                            return;
                        }else{
                            $.messager.alert('LDAP','Coud not login with this credentials!');
                        }
                        $('div#divLoader').window('close');
                    }
                });
            }
            return false;
        });
        
        $('#passwordFieldSmall, #userFieldSmall').keyup(function(e) {
            if(e.keyCode == 13) {
                $('#formIndexLoginSmall').submit();
            }
        });
    });
</script>
<style>
    #IndexLoginDSmall{
        background-color: #FFF;

        -moz-box-shadow: 0 0 10px #AAA;
        -webkit-box-shadow: 0 0 10px #AAA;
        box-shadow: 0 0 10px #AAA;

        -moz-border-radius: 0 20px;
        -webkit-border-radius: 0 20px;
        -khtml-border-radius: 0 20px;
        border-radius: 0 20px;
        border: 1px solid #CCC;
        margin: 10px;
    }
    #IndexLoginDSmall #formIndexLoginSmall{
        margin: 2px;
        font-size: 1em;
        overflow: hidden;
    }

    #IndexLoginDSmall #formIndexLogin div{
        margin: 2px;
    }
    #IndexLoginDSmall #formIndexLoginSmall div label{
        width:30%;
        vertical-align: top;
        display: block;
        float: left;
        text-align: right;
        margin: 3px 5px 0 0;
        color: #555;
    }
    #IndexLoginDSmall #formIndexLoginSmall div input{            
        font-size: 1em;
    }
    #IndexLoginDSmall #formIndexLoginSmall #submitBtnSmall{            
        text-align: center;
        width: 100%;

    }

    #IndexLoginDSmall #fm .fitem {
        width:100%;
        padding: 3px;
        clear: both;
    }
    #IndexLoginDSmall #fm .fitem label{
        width:30%;
        vertical-align: top;
        display: block;
        float: left;
        text-align: right;
        margin: 3px 5px 0 0;
        color: #555;
    }

    /* form style */

    #IndexLoginDSmall input { 
        width: 60%;
        border: solid 1px #E5E5E5;
        outline: 0;
        background: #FFFFFF left top repeat-x;
        background: -webkit-gradient(linear, left top, left 25, from(#FFFFFF), color-stop(4%, #EEEEEE), to(#FFFFFF));
        background: -moz-linear-gradient(top, #FFFFFF, #EEEEEE 1px, #FFFFFF 25px);
        box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
        -moz-box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
        -webkit-box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
        margin: 5px 1px;
    }

    #IndexLoginDSmall input:hover, input:focus { 
        border-color: #C9C9C9; 
        -webkit-box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 8px;
    }


</style>
<div id="IndexLoginDSmall" title="Login">  
    <form method="post" action="" id="formIndexLoginSmall">
        <div class="fitem"><label>Usuário</label><input name="userSmall" id="userFieldSmall" ></div>
        <div class="fitem"><label>Senha</label><input name="passSmall" type="password" id="passwordFieldSmall"  ></div>
        <div id="submitBtnSmall"><a href="#" id="submitIndexLoginBtnSmall" class="easyui-linkbutton" iconCls="icon-key--plus" onclick="$('#formIndexLoginSmall').submit();">Login</a> </div>
    </form>
</div>
<?php
}else{
?>
<script>
    $(function() {
        $('#btnLogoutSmall').linkbutton({  
            iconCls: 'icon-cross-circle'  
        });
        $('#btnLogoutSmall').bind('click', function(){  
            document.location = '<?php echo $this->Html->url(array('controller' => 'CoreUsers', 'action' => 'logout'));?>';  
        });
    });
</script>
<style>
    #submitBtnSmall{
        text-align: center;
        padding: 5px;
    }
</style>
<div id="submitBtnSmall">
     <a id="btnLogoutSmall" href="#"><?php echo __('Logout'); ?></a>
</div>
<?php
}
?>